home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1991 …esperately Seeking Seven / Desperately Seeking Seven.2mg / Dev.CD.8 / Essentials / Tools / File.Type.Notes / FTN.54.DD3E < prev    next >
Encoding:
Text File  |  1989-04-04  |  51.9 KB  |  1,034 lines  |  [04] ASCII Text (0x0000)

  1. Apple II
  2. File Type Notes
  3. _____________________________________________________________________________
  4.                                                   Developer Technical Support
  5.  
  6.  
  7. File Type:         $54 (84)
  8. Auxiliary Type:    $DD3E
  9.  
  10. Full Name:     Medley Desktop Publishing Document
  11. Short Name:    Medley Document
  12.  
  13. Written by:    Matt Deatherage & Eric Soldan                         May 1989
  14.  
  15. Files of this type and auxiliary type contain documents for Medley(TM).
  16. _____________________________________________________________________________
  17.  
  18. Medley is a WYSIWYG application that integrates word processing, paint, and 
  19. page layout programs, with the addition of a spelling checker and thesaurus.  
  20. The page layout function supports various shapes for art and text areas.  Text 
  21. automatically wraps around or within these areas, including irregularly shaped 
  22. regions.  The word processor is full-featured, as is the paint program.  The 
  23. dictionary has 80,000 words.
  24.  
  25. For more information on Medley, contact:
  26.  
  27.                 Milliken Publishing Company
  28.                 1100 Research Blvd.
  29.                 St. Louis, MO  63132
  30.                 Attention:  Medley Technical Support
  31.                 (314) 991-4220
  32.  
  33. The Medley file format is copyrighted (C) 1988 by Milliken Publishing Company 
  34. and is printed here with permission.
  35.  
  36. Definitions
  37.  
  38. The following definition is used in this document in addition to those defined 
  39. for all Apple II file types:
  40.  
  41. C String    A series of ASCII bytes terminated with a byte of $00.  
  42.             There is no count byte at the beginning, as is the case for 
  43.             the String type (also referred to as a "Pascal string").
  44.  
  45.  
  46. File Structure
  47.  
  48. Medley files are basically standard, single-linked tree structures.  There is 
  49. a single object at the top of the tree, and other objects may branch off this 
  50. parent object.  Each child object is linked to the parent by a pointer to the 
  51. child contained within the parent object.  A non-standard thing about the 
  52. Medley tree structure is that some objects may have regions or polygons 
  53. associated with them.  The handles to these objects are stored in the parent 
  54. object when in memory, but on disk these handles are quite meaningless.  
  55. Because of this difference, the regions or polygons are simply appended to the 
  56. parent object itself when written to disk.  The size of the region or polygon 
  57. is added to the size of the parent object, giving an aggregate size for the 
  58. complex object on disk.
  59.  
  60. The file is written to disk in an order based on a simple tree-walking 
  61. algorithm.  This algorithm starts with the highest parent object and writes it 
  62. to disk.  The parent object is checked for child objects.  If one exists, it 
  63. is written to disk, and then it is checked for child objects.  This tree-
  64. walking continues until an object runs out of children.  When that occurs, 
  65. Medley backs up one tree level, writes the next child object to disk, and 
  66. scans it for children.  This method continues until all objects are written to 
  67. disk.
  68.  
  69. For example, if a parent object named A had two child objects named B and C, 
  70. where B had children E and F, and C had children G and H, the objects would be 
  71. written to disk in the following order:  A, B, D, E, C, F, G.  Figure 1 
  72. illustrates this structure.
  73.                                  _________
  74.                                 |         |
  75.                                 |    A    |
  76.                                 |_________|
  77.                      |---------------|---------------|
  78.                  ____|____                       ____|____ 
  79.                 |         |                     |         |
  80.                 |    B    |                     |    C    |
  81.                 |_________|                     |_________|
  82.              |-------|-------|---------------|-------|-------|
  83.          ____|____       ____|____       ____|____       ____|____
  84.         |         |     |         |     |         |     |         |
  85.         |    D    |     |    E    |     |    F    |     |    G    |
  86.         |_________|     |_________|     |_________|     |_________|
  87.  
  88.              Figure 1-Example of Parent and Child Tree Structure
  89.  
  90. Some Medley objects, when in memory, have handles to other objects (such as 
  91. regions or polygons) in them.  Since handles are meaningless on disk, Medley 
  92. stores these complex objects in an aggregate form by writing the contents of 
  93. each associated handle to disk following the regular object.
  94.  
  95. The Objects and Their Formats
  96.  
  97. All objects have a common 13-byte header, which is as follows:
  98.  
  99. type           (+000)    Byte    The type of the object.   Possible 
  100.                                  values are:
  101.                                  0 = Null Object (never saved to disk)
  102.                                  1 = Root Object (never saved to disk)
  103.                                  2 = File Object
  104.                                  3 = Page Object
  105.                                  4 = Paragraph Object
  106.                                  5 = Area Object
  107.                                  6 = Art Object
  108.                                  10 = Document Dictionary Object.
  109.                                  Objects 7, 8 and 9 are for posting 
  110.                                  undo events.  Since these are not 
  111.                                  saved to disk, they are irrelevant 
  112.                                  for the file format.
  113. numChildren    (+001)    Word    The number of children for this 
  114.                                  object.  Children of the children 
  115.                                  are not included.
  116. endData        (+003)    Long    The size of this object on the 
  117.                                  disk, not counting associated 
  118.                                  handles (such as regions and 
  119.                                  polygons).
  120. reserved       (+007)    Long    Reserved; set to zero when 
  121.                                  creating files.
  122. objRefNum      (+011)    Word    The reference number of this 
  123.                                  object, generally zero.
  124.  
  125. Each object has the header listed above followed by object-specific data.  For 
  126. this reason, the description of each object will start with offset +013 (the 
  127. byte following the header).
  128.  
  129. The File Object
  130.  
  131. rect           (+013)    4 Words Standard QuickDraw II rectangle, 
  132.                                  giving the boundary rectangle for 
  133.                                  the entire file.
  134. pathName       (+021)  129 Bytes Class zero pathname for the 
  135.                                  file on disk (used by the save 
  136.                                  command).
  137. saved          (+150)    Byte    This byte is 1 if no changes have 
  138.                                  been made to the file since the last 
  139.                                  save.
  140. windowPtr      (+151)    Long    Pointer to the window for this 
  141.                                  file.  When creating files, set to 
  142.                                  zero.
  143. wndwNameIndx   (+155)    Byte    Index into table of window 
  144.                                  names.  Set to zero when creating 
  145.                                  files
  146. windowOrigin   (+156)    2 Words QuickDraw II point 
  147.                                  representing the global origin of 
  148.                                  this file's window.
  149. windowSize.h   (+160)    Word    Height of window in pixels.  
  150.                                  Add to top edge of window to get 
  151.                                  bottom edge of window.
  152. windowSize.v   (+162)    Word    Height of window in pixels.  
  153.                                  Add to left of window to get right 
  154.                                  edge of window.
  155. COrigin        (+164)    Long    QuickDraw II point representing the 
  156.                                  scroll bar origin of this file's 
  157.                                  window.  When creating files, set 
  158.                                  this to whatever origin you wish 
  159.                                  Medley to display.  Make sure that 
  160.                                  the coordinate is valid.
  161. editHndl       (+168)    Long    Handle to the paragraph containing 
  162.                                  the cursor.  This is converted to a 
  163.                                  child number on disk, since handles 
  164.                                  on disk are meaningless.
  165. editOffset     (+172)    Word    Offset to the cursor within the 
  166.                                  paragraph pointed to by editHndl.
  167. cursor         (+174)    4 Words Standard QuickDraw II rectangle, 
  168.                                  giving the rectangle used for the 
  169.                                  insert cursor.  This can be set to a 
  170.                                  null rectangle when creating files, 
  171.                                  and will be calculated when the file 
  172.                                  is loaded.
  173. showAllBorders (+182)    Byte    If this is set to one, then 
  174.                                  all area borders will display, 
  175.                                  regardless of each area's border 
  176.                                  display setting.
  177. updateRect     (+183)    4 Words Standard QuickDraw II 
  178.                                  rectangle used for posting specific 
  179.                                  updates for the interruptible word 
  180.                                  processor.  When creating files, set 
  181.                                  this to a null rectangle.
  182. topMrgn        (+191)    Fixed   The top margin in inches.
  183. bottomMrgn     (+195)    Fixed   The bottom margin in inches.
  184. leftMrgn       (+199)    Fixed   The left margin in inches.
  185. rightMrgn      (+203)    Fixed   The right margin in inches.
  186. gutterMrgn     (+207)    Fixed   The gutter margin in inches.
  187. pageWidth      (+211)    Fixed   The width of the page in inches.
  188. pageHeight     (+215)    Fixed   The height of the page in 
  189.                                  inches.
  190. selectPage     (+219)    Word    The active page for area 
  191.                                  editing.
  192. numSelected    (+221)    Word    The number of areas currently 
  193.                                  selected by the user.
  194. sizingDot      (+223)    Word    The sizing dot number of an area 
  195.                                  that was last clicked.  This sizing 
  196.                                  dot will be used as the current 
  197.                                  sizing dot when the arrows are used 
  198.                                  to size an area.
  199. effectivePage  (+225)    Word    The page number of the page 
  200.                                  the user was effectively editing.  
  201.                                  This is different from selectPage 
  202.                                  when the user was editing global 
  203.                                  areas at save time, for global areas 
  204.                                  are treated as on page zero.
  205. printRecord    (+227)  140 Bytes A standard IIGS Print 
  206.                                  Manager print record; the one in use 
  207.                                  for this document at save time.  
  208.                                  This field can be undefined, if the 
  209.                                  printRecordDefined field is zero.
  210. interruptMode  (+367)    Word    Currently undocumented.  (Set 
  211.                                  to zero.)
  212. editScroll     (+369)    Byte    Currently undocumented.  (Set to 
  213.                                  zero.)
  214. firstHndl      (+370)    Long    Handle where wrap-around regions 
  215.                                  should actually start; i.e., where 
  216.                                  an update is needed.  When creating 
  217.                                  files, set this to zero.
  218. firstMrn       (+374)    Word    MiniRect number (line number of 
  219.                                  paragraph) where wrap-around regions 
  220.                                  should actually start; i.e., where 
  221.                                  an update is needed.  When creating 
  222.                                  files, set this to zero.
  223. selectMode     (+376)    Word    Some text is selected if this is 
  224.                                  1.  Each paragraph will indicate the 
  225.                                  range of characters selected within 
  226.                                  that paragraph.  This allows the 
  227.                                  screen update routine to quickly 
  228.                                  determine which characters in a 
  229.                                  paragraph should be drawn selected.
  230. showPgphMarks  (+378)    Byte    Indicates whether paragraph 
  231.                                  marks are currently being shown.
  232. showSpaces     (+379)    Byte    Indicates whether spaces are 
  233.                                  shown with marks and tabs are shown 
  234.                                  with arrows.
  235. showMoveChangeInfo
  236.                (+380)    Byte    Indicates whether the Move/Change window 
  237.                                  is active.
  238. moveChangeInfoRect
  239.                (+381)    4 Words Standard QuickDraw II Rectangle giving 
  240.                                  the position of the Move/Change 
  241.                                  window.
  242. addNewUndo     (+389)    Byte    Currently undocumented.
  243. revNum         (+390)    Word    Revision number of the version of 
  244.                                  Medley that created this file.  For 
  245.                                  files created following this 
  246.                                  standard, use $0100 (for Medley 
  247.                                  2.0).
  248. showRulers     (+392)    Byte    Indicates whether the rulers are 
  249.                                  showing.
  250. windowType     (+393)    Word    The type of window this is.  0 = 
  251.                                  document, 1 = clipboard.  When 
  252.                                  creating files, set this to zero.
  253. auxDictPath    (+395)  129 Bytes Class zero GS/OS pathname 
  254.                                  to the auxiliary dictionary file for 
  255.                                  this document.  When creating files, 
  256.                                  set this to a null pathname (a 
  257.                                  length byte of zero).
  258. grayScale      (+524)    Word    Whether or not grayScale mode is 
  259.                                  active.  Zero for color, one for 
  260.                                  grayScale.
  261. printRecordDefined
  262.                (+526)    Word    Non-zero if a print record is defined.  
  263.                                  This is used because the Printer and 
  264.                                  Port drivers must be loaded before 
  265.                                  calling PrDefault or PrValidate, and 
  266.                                  that means the boot disk must be on 
  267.                                  line.  If Medley knows the print 
  268.                                  record is good, it proceeds without 
  269.                                  calling the Print Manager.
  270. evenPageNumText
  271.                (+528)   48 Bytes The text for even-numbered pages to be 
  272.                                  displayed by the page number.
  273. oddPageNumText
  274.                (+576)   48 Bytes The text for odd-numbered pages to be 
  275.                                  displayed by the page number.
  276. pageNumInfo    (+624)   32 Words A word for each of the 
  277.                                  pages possible in the file, through 
  278.                                  the absolute maximum of thirty-two.
  279. affectPageRange(+688)    2 Bytes The range of pages 
  280.                                  affected by the Medley "Change Page 
  281.                                  Numbers" command.  The first byte is 
  282.                                  the beginning page; the second byte 
  283.                                  is the ending page.
  284. pageNumFont    (+690)    4 Bytes A Font Manager FontID, 
  285.                                  identifying the font used for the 
  286.                                  page numbers.  This is a two-byte 
  287.                                  font family number, followed by a 
  288.                                  one-byte font style and one-byte 
  289.                                  font size.
  290. startPageNum   (+694)    Word    The page number of the first 
  291.                                  page.  This is a zero-based counter; 
  292.                                  page one is represented as zero.
  293. offsetFromEdge (+696)    Word    The distance in points that 
  294.                                  the page numbering text appears from 
  295.                                  the edge of the paper.
  296.  
  297. Note:    The following three fields are in Medley 2.0 files, but do not 
  298.          exist in Medley 1.0 files.  If you are reading a 1.0 file, the 
  299.          value of revNum will be $0000.  If reading a 1.0 File Object, 
  300.          resize it to 2.0 size (including the three fields below) and 
  301.          initialize their values to the values given below.
  302.  
  303. maxNumPages    (+698)    Word    The maximum number of pages in 
  304.                                  this document.  When creating new 
  305.                                  files, initialize this to 32 ($20) 
  306.                                  unless condensed (below) is non-
  307.                                  zero.  If condensed is non-zero, you 
  308.                                  really have to hurt yourself to get 
  309.                                  this field right.  Below is the 
  310.                                  algorithm Medley uses to calculate 
  311.                                  this field (in something close but 
  312.                                  not exactly related to pseudo-code).  
  313.                                  Please recall that all variables 
  314.                                  relating to the margins (taken from 
  315.                                  the file object) are Fixed.
  316.  
  317. workHeight := topMrgn + bottomMrgn
  318. if [condensed is non-zero] then workHeight := workHeight * 2
  319. workHeight := pageHeight - workHeight
  320. workHeight := workHeight * [pixels per vertical inch]
  321. workHeight := workHeight + $0000FFFF
  322. [this counts a fractional point as a whole point]
  323. i := HiWord(workHeight) [this gives the integer portion]
  324. i := i + 3 [accounts for 3-pixel page breaks]
  325. i := (16384 - 208) / i [gives number of pages in conceptual 
  326. drawing space.  Since Medley allows 48-point characters plus 
  327. leading, the tallest a text rectangle may be is 208 pixels.  Text 
  328. that does not fit in maxNumPages is kept around in a non-
  329. displayable, non-editable, non-printable page.  Any shortening of 
  330. the document will cause some or all of the previously non-
  331. displayed text to flow up into the document.]
  332. i := min(32,i) [32 is the absolute maximum number of pages Medley 
  333. allows due to QuickDraw's conceptual drawing space limitations.]
  334.  
  335. maxNumPages := i
  336.  
  337. condensed      (+700)    Word    Indicates whether the document is 
  338.                                  designed to use condensed printing.  
  339.                                  If non-zero, the document is 
  340.                                  designed to use condensed printing.  
  341.                                  When creating files, it is easiest 
  342.                                  not to deal with condensed printing, 
  343.                                  so set this field to zero.  However, 
  344.                                  if you wish to create a document 
  345.                                  that Medley may edit and print as 
  346.                                  condensed, you must correctly relate 
  347.                                  this field to the previous one by 
  348.                                  the algorithm given above.
  349. reserved       (+702)    6 Bytes These six bytes should be set 
  350.                                  to zero.
  351.  
  352.  
  353. The Page Object
  354.  
  355. Pages are the first-level children of files.  There is one page object for 
  356. each page in a document (file object).
  357.  
  358. rect           (+013)    4 Words Standard QuickDraw II rectangle 
  359.                                  giving the boundary rectangle for 
  360.                                  this page.
  361. wrapDir        (+021)    Byte    The direction of word-wrapping.
  362.                                  1 = Down, 2 = across.
  363. rgn            (+022)    Long    Handle to the region for this page in 
  364.                                  memory.  The region is the page 
  365.                                  rectangle less any areas on that 
  366.                                  page.  Global areas are not 
  367.                                  subtracted from this region.  They 
  368.                                  are subtracted from the page 
  369.                                  rectangle for the global page (page 
  370.                                  zero).  On disk, where the page 
  371.                                  region would be written, you can 
  372.                                  write a 10, followed by the 
  373.                                  rectangle for the page.  This is a 
  374.                                  rectangular region.  The aggregate 
  375.                                  size of the page object on disk must 
  376.                                  include these 10 bytes.  This is 
  377.                                  assuming, of course, that there are 
  378.                                  no areas on that page to make the 
  379.                                  page region non-rectangular.
  380. hideGlobalArt  (+026)    Byte    A non-zero value indicates 
  381.                                  that global art is not displayed on 
  382.                                  this page.
  383. hideGlobalPageParts
  384.                (+027)    Byte    A non-zero value indicates that global 
  385.                                  page parts are not displayed on this 
  386.                                  page.
  387.  
  388. The Paragraph Object
  389.  
  390. Paragraphs are the children of the file object; they are not the children of 
  391. page objects since a paragraph may be seen on more than one page or page part.  
  392. Paragraph objects are, however, stored on disk immediately following page 
  393. objects and their children.  Paragraph objects are first-level objects also.
  394.  
  395. wrapHere       (+013)    Word    Insertion offset point in 
  396.                                  paragraph data where wrapping should 
  397.                                  continue.  For wrapping from 
  398.                                  beginning of paragraph, set this 
  399.                                  field to zero.
  400. fullWrap       (+015)    Word    Same as wrapHere, but indicates at 
  401.                                  what point miniRect construction or 
  402.                                  reconstruction must continue.  
  403.                                  Again, for full-wrapping of a 
  404.                                  paragraph, set to zero.
  405. rulerOffset    (+017)    Word    Offset in bytes from beginning 
  406.                                  of paragraph object to indicate 
  407.                                  where the ruler starts.  (The ruler 
  408.                                  is just before the character data, 
  409.                                  just after the miniRects.)  If there 
  410.                                  is no ruler, then the default ruler 
  411.                                  is used by Medley.  (If the 
  412.                                  dataOffset value is the same as the 
  413.                                  rulerOffset, then there is no ruler, 
  414.                                  and the default ruler will be used.)  
  415.                                  The default ruler has tabs at each 
  416.                                  1/2 inch mark, no indent or 
  417.                                  paragraph indent, and the right 
  418.                                  margin is at maximum.
  419. dataOffset     (+019)    Word    Offset in bytes from beginning 
  420.                                  of paragraph object to indicate 
  421.                                  where character data starts.  If 
  422.                                  there are no miniRects built yet 
  423.                                  (probable if file is being created 
  424.                                  outside Medley) and there is no 
  425.                                  ruler, then this value will be a 32.
  426. numRects       (+021)    Word    The number of discrete text 
  427.                                  rectangles in this paragraph.  When 
  428.                                  creating a file, set fullWrap to 
  429.                                  zero, and numRects to zero, and 
  430.                                  place your character data starting 
  431.                                  at byte 32 of a paragraph object, 
  432.                                  and the rectangles will be built 
  433.                                  when the file is loaded by Medley as 
  434.                                  wrap occurs.
  435. begInvOffset   (+023)    Word    Offset from the beginning of 
  436.                                  the character data where inverse 
  437.                                  text starts in this paragraph.
  438. endInvOffset   (+025)    Word    Offset from the beginning of 
  439.                                  the character data where inverse 
  440.                                  text ends in this paragraph.
  441. topLeading     (+027)    Byte    The number of pixels leading 
  442.                                  above each line in this paragraph.
  443. botLeading     (+028)    Byte    The number of pixels leading 
  444.                                  below each line in this paragraphs.
  445. begPgphGap     (+029)    Byte    The number of pixels extra 
  446.                                  leading above this paragraph.
  447. endPgphGap     (+030)    Byte    The number of pixels extra 
  448.                                  leading below this paragraph.
  449. flags          (+031)  Flag Byte Bits 0 and 1 are used to 
  450.                                  indicate justify mode.
  451.                                  00 = left justify.
  452.                                  01 = right justify.
  453.                                  10 = center justify.
  454.                                  11 = full justify.
  455.                                  Bit 7 indicates a page-break after
  456.                                  this paragraph.
  457. miniRects      (+032)  MiniRects Any miniRects, if any, are 
  458.                                  contained here.  The number of 
  459.                                  miniRects is given by numRects 
  460.                                  above.
  461.  
  462. MiniRects have the following format:
  463.  
  464. miniRect.rect  (+000)    4 Words Standard QuickDraw II 
  465.                                  rectangle that is calculated by the 
  466.                                  wordWrap routine to bound a line of 
  467.                                  text.
  468. mr.begOffset   (+008)    Word    Offset from start of character 
  469.                                  data to the first character this 
  470.                                  miniRect bounds.
  471. mr.endOffset   (+010)    Word    Offset from start of character 
  472.                                  data to just past the last character 
  473.                                  this miniRect bounds.
  474.  
  475. A Ruler in the document will be after the miniRects, if there are 
  476. any.  The offset to the Ruler is given by rulerOffset.  Rulers are 
  477. formatted as follows:
  478.  
  479. leftPgphMrgn   (+000)    Byte    The left margin for this 
  480.                                  paragraph, in sixteenths of an inch.
  481. rightPgphMrgn  (+001)    Byte    The right margin for this 
  482.                                  paragraph, in sixteenths of an inch.  
  483.                                  This is an offset from the default 
  484.                                  right margin from Medley's "Set 
  485.                                  margins" command.  For example, the 
  486.                                  value 16 represents a right margin 
  487.                                  one inch to the left of the default 
  488.                                  right margin.
  489. pgphIndent     (+002)    Byte    The indentation for this 
  490.                                  paragraph, in sixteenths of an inch.
  491. numTabs        (+003)    Byte    The number of tabs in this ruler.
  492. tabs           (+004)    Tabs    There are numTabs of these.
  493.  
  494. Tabs are formatted as follows:
  495.  
  496. tab            Flag Word         Tabs consist of a high byte of flags 
  497.                                  and low byte of position.  The bits 
  498.                                  are assigned as follows:
  499.                                  Bits 15-12 = Reserved; set to zero.
  500.                                  Bits 11-10 = Tab Leader style:
  501.                                             00 = No leader
  502.                                             01 = Leader of dots (.......)
  503.                                             10 = Leader of dashes ( - - )
  504.                                             11 = Solid Leader (_________)
  505.                                  Bits 9-8 = Tab Type:
  506.                                             00 = Left Tab
  507.                                             01 = Right Tab
  508.                                             10 = Center Tab
  509.                                             11 = Decimal Tab
  510.                                  Bits 7-0 = Byte value; the 
  511.                                             position of this tab as an 
  512.                                             offset from the left 
  513.                                             margin in sixteenths of an 
  514.                                             inch.  A value of sixteen 
  515.                                             indicates a tab one inch 
  516.                                             to the right of the left 
  517.                                             margin.
  518.  
  519. Following miniRects and rulers is the actual character data for 
  520. this paragraph.  This is all Bytes.  However, a Byte value of 
  521. $01 through $07 indicates the beginning of a Font Escape.  Font 
  522. Escapes indicate changes in style or size of the text, and are 
  523. formatted as follows:
  524.  
  525. FontEscape     (+000)    Byte    An indication of the type of 
  526.                                  text the following fontID affects:
  527.                                  1 = Regular Text
  528.                                  2 = Superscript Text
  529.                                  3 = Subscript Text
  530.                                  4-7 = Reserved; do not use
  531. fontID         (+001)    4 Bytes A Font Manager FontID, 
  532.                                  identifying the font used for the 
  533.                                  page numbers.  This is a two-byte 
  534.                                  font family number, followed by a 
  535.                                  one-byte font style and one-byte 
  536.                                  font size.
  537.  
  538. The text portion of a paragraph always begins with a Font Escape 
  539. and ends with the end-of-paragraph character Byte $A6.  This 
  540. makes the minimum size of a paragraph (assuming no miniRects or 
  541. rulers) thirty-eight bytes (32 bytes for the Paragraph Object, 
  542. five bytes for the Font Escape and one byte for the $A6).
  543.  
  544.  
  545. The Area Object
  546.  
  547. Area Objects are the children of pages or paragraphs.
  548.  
  549. type           (+013)    Byte    The type of area this area object 
  550.                                  describes.  Possible values are:
  551.                                  0 = Null Area
  552.                                  1 = Group Area
  553.                                  2 = Rectangular Area
  554.                                  3 = Round Rectangular Area
  555.                                  4 = Oval Area
  556.                                  5 = Polygon Area
  557. select         (+014)    Byte    This value is one if this area is 
  558.                                  selected.
  559. showBorder     (+015)    Byte    This value is one if the border 
  560.                                  of this area is showing.
  561. contentType    (+016)    Byte    0 = Art, 1 = Wrap Down,
  562.                                  2 = Wrap Across.
  563. rgn            (+017)    Long    Handle to the region that describes the 
  564.                                  shape of this area.  On disk, this 
  565.                                  region is at the end of this object 
  566.                                  (see the Reading The File section of 
  567.                                  this Note).
  568. interiorRgn    (+021)    Long    Handle to the regions that 
  569.                                  describes the interior of this area.  
  570.                                  On disk, this region is at the end 
  571.                                  of this object (see the Reading The 
  572.                                  File section of this Note).
  573. sizingRgn      (+025)    Long    Handle that contains all the 
  574.                                  sizing dots.  It is too slow to draw 
  575.                                  them one at a time.  Also, detecting 
  576.                                  that the user clicked in a sizing 
  577.                                  dot can be done quickly -- just not 
  578.                                  which one.
  579. flags          (+029)    Word    Only bit zero of this word is 
  580.                                  significant; if set it indicates 
  581.                                  this area should be printed to 
  582.                                  LaserWriters in gray-scale.  All 
  583.                                  other bits of this word should be 
  584.                                  zero.
  585. reserved       (+031)    Word    Reserved for Milliken.  Set to 
  586.                                  zero.
  587.  
  588. At this point is the description of the area itself.  This 
  589. description varies on the type field above:
  590.  
  591. For rectangles (type = 2):
  592.  
  593. rect           (+033)    4 Words Standard QuickDraw II rectangle 
  594.                                  describing the rectangle for this 
  595.                                  area.
  596. For round rectangle (type = 3):
  597.  
  598. rect           (+033)    4 Words Standard QuickDraw II rectangle 
  599.                                  describing the boundary rectangle 
  600.                                  for the round rect.
  601. height         (+041)    Word    The height of the oval portion of 
  602.                                  the rectangle.
  603. width          (+043)    Word    The width of the oval portion of the 
  604.                                  rectangle.
  605.  
  606. For ovals (type = 4):
  607.  
  608. oval           (+033)    4 Words A standard QuickDraw II rectangle 
  609.                                  describing the bounding rectangle 
  610.                                  for this oval.  The oval drawn is 
  611.                                  the ellipse inscribed in this 
  612.                                  rectangle.
  613.  
  614. For Polygons (type = 5):
  615.  
  616. polygon        (+033)    Bytes   A handle to a QuickDraw II 
  617.                                  polygon.  This handle may be passed 
  618.                                  to QD Polygon routines.  On disk, 
  619.                                  this polygon is appended to the end 
  620.                                  of this object (see the Reading The 
  621.                                  File section on this Note).
  622.  
  623. These objects are the last items in the area object.
  624.  
  625. The Art Object
  626.  
  627. Art Objects are the children of pages, paragraphs or areas.
  628.  
  629. BBox           (+013)    4 Words A standard QuickDraw II rectangle 
  630.                                  representing the bounding box of 
  631.                                  this art object.
  632. offsetFromRgn  (+021)    2 Words Normally zero.  The area 
  633.                                  containing an art image can be grown 
  634.                                  and shrunk.  The art within it is 
  635.                                  not clipped to the bounding 
  636.                                  rectangle of the area until the user 
  637.                                  deselects the area.  (If it is saved 
  638.                                  to disk while selected, then it is 
  639.                                  saved unclipped).  This allows the 
  640.                                  user to experiment with different 
  641.                                  shapes without clipping the drawing 
  642.                                  within.  If the drawing is to the 
  643.                                  left of the left edge of the area, 
  644.                                  or is above the top edge, then this 
  645.                                  offset indicates by how much.
  646. artImage       (+025)    Bytes   The actual bitmap of the art 
  647.                                  image.
  648.  
  649. The Document Dictionary Object
  650.  
  651. The Document Dictionary Object is the very last child of the file object, and 
  652. contains all the words the spelling checker should ignore even though they are 
  653. not in the main dictionary.
  654.  
  655. count          (+013)    Word    The number of word entries in this 
  656.                                  dictionary object.
  657. wordList       (+015)    Word Entries    List of dictionary word 
  658.                                          entries.
  659.  
  660. The format of word entries is as follows:
  661.  
  662. recordLength   (+000)    Byte    The length of this record.
  663. replaceFlag    (+001)    Byte    Reserved, set to zero.
  664. newWord        (+002)    C String    The word in question.  This 
  665.                                      word should be counted as spelled 
  666.                                      correctly, and is not in the Main or 
  667.                                      Auxiliary Dictionary.  
  668.  
  669. The length of a record is the length of string plus three bytes 
  670. (one for recordLength, one for replaceFlag, and a zero termination 
  671. byte).
  672.  
  673.  
  674. Reading the File
  675.  
  676. When reading a Medley file, objects with regions or polygons will have to be 
  677. treated specially, since the handles in the objects are invalid and the 
  678. regions or polygons actually follow the object in the disk file.
  679.  
  680. A sequence for reconstructing Medley files in memory is as follows:
  681.  
  682.     1.  Open the file, or set the mark to zero on an open file.
  683.     2.  Start with a handle that is 13 ($0D) bytes long.  Pass this 
  684.         handle to the routine starting in step three.
  685.     3.  Save the handle passed to this routine, and read four bytes 
  686.         from disk.  This Long is the total size of an object, including 
  687.         any regions or polygons appended.
  688.     4.  Read the 13-byte object header into the handle passed to this 
  689.         routine.  The endData field of the header gives the size of the 
  690.         object, minus any associated regions or polygons.  Resize the 
  691.         object's handle (the handle passed to you) to this size.
  692.     5.  Read the rest of the object (endData - 13 bytes) into the 
  693.         object's handle.
  694.     6.  Save the value of numChildren in a local variable and set the 
  695.         numChildren field in the object header to zero.  The field in 
  696.         the header represents the number of children read from disk; 
  697.         setting this to zero properly indicates that you haven't read 
  698.         any of the children yet.
  699.     7.  Look at the object type field.  If the object is a file, area, 
  700.         or page object, it may have a region associated with it.  If the 
  701.         object is an area object, it may also have a polygon associated 
  702.         with it (if the area type field indicates this is so).  You can 
  703.         tell if the object has any appended structures by comparing the 
  704.         total object size (read in step three) with the endData field 
  705.         (read in step four); if an object has no appended structures, 
  706.         the two values will be the same.
  707.  
  708.         If there are structures appended to the object, first zero all 
  709.         the handles to the regions inside the object.  This allows 
  710.         elegant error recovery if an error occurs while reading the 
  711.         region or polygon.   When the handles are zeroed, read the next 
  712.         two bytes from the disk.  This Word is the size of the region or 
  713.         polygon in bytes.  Create a handle of that size, place it in the 
  714.         object's field for this handle, and place the size Word in the 
  715.         first two bytes of the new handle.  Now read the object from 
  716.         disk into the new handle starting at the beginning +002 (past 
  717.         the size Word).
  718.  
  719.         Continue in this fashion until all appended regions or polygons 
  720.         have been read from disk.  Any appended structures will be 
  721.         stored in the same order as their handles occur in the object.
  722.  
  723.         Note:    By zeroing the handles before reading the objects, you 
  724.                  can return from this function with an error, and the 
  725.                  calling routine will be able to dispose of all handles 
  726.                  that were actually created.  The calling routine will know 
  727.                  if a handle was actually created or not by examining the 
  728.                  handle field in the object; NIL handles were not created.
  729.  
  730.     8.  Execute a loop for the old number of children (0 to 
  731.         oldNumChildren-1):
  732.     9.  Create an object that is 13 ($0D) bytes long.  Add this handle 
  733.         to the end of the parent object that was last read.  Increment 
  734.         the number of children.  You have just added a child into the 
  735.         child table for an object.
  736.    10.  Call the recursive subroutine beginning in step three, passing 
  737.         it the handle you just created.  If it returns an error, return 
  738.         the error.  This gets you out of the recursion with the correct 
  739.         error, no matter how many levels deep you are.
  740.    11.  Keep looping until out of children to read.  The EOF condition 
  741.         does not have to be checked, since you will run out of children 
  742.         when you reach the end of the file.  If an EOF is reached before 
  743.         you read all the children, you did something wrong.
  744.    12.  Return no error--the file was successfully read.
  745.    13.  When done with all this, you will return to the code just 
  746.         beyond step two, where you first called the recursive subroutine 
  747.         at step three.  If an error is returned, dispose of all the 
  748.         handles created by the recursive function.  Even if the file 
  749.         read is aborted, the tree is complete for as much as was read.  
  750.         (This is why the numChildren field is incremented as you read 
  751.         the file.)  An alternate way to handle this is to use a 
  752.         different userID for the handles created when reading the file; 
  753.         this allows you to dispose of all of them with one DisposeAll 
  754.         call.
  755.   14.   Close the file if you opened it, or reset the mark to its 
  756.         previous position if it was already open.
  757.  
  758. The entire file does not have to be read from disk.  By using the size field, 
  759. you can skip to the next object in the file.  Using this technique, you can 
  760. scan the file for whatever it is that interests you.
  761.  
  762. Note:    You may have noticed that objects successfully created in 
  763.          memory will have a table of handles to children at the end.  
  764.          Objects on disk will not have these handles, since the handles on 
  765.          disk are meaningless.  The child handle table is reconstructed as 
  766.          the file is loaded into memory.
  767.  
  768.  
  769. Object Ordering
  770.  
  771. The file object is the first you will encounter in a Medley file.  Its 
  772. children are ordered as follows:
  773.  
  774. Page Object--Page #0.  This is the global page object, containing all global 
  775.                        areas.
  776. Page Object--Page #1.  This is the page object for page #1; it must exist.
  777.  
  778. Other objects are optional, but will appear in the following order:
  779.  
  780. Page #2 through Page #n
  781. Paragraph #1 through Paragraph #n
  782. Dictionary Object
  783.  
  784.  
  785. Some Example Structures
  786.  
  787. Medley was written mostly in C.  Below are some structures relevant to C 
  788. programs reading Medley files.  Descriptions of the fields may be found 
  789. earlier in this Note.
  790.  
  791. #define NULLOBJ       0    /* Object type assignments. */
  792. #define ROOTOBJ       1    /* These are used in the deskObj 'types' field. */
  793. #define FILEOBJ       2
  794. #define PAGEOBJ       3
  795. #define PGPHOBJ       4
  796. #define AREAOBJ       5
  797. #define ARTOBJ        6
  798. #define DOCDICTOBJ    10
  799.  
  800. #define AREANULL      0    /* Area object sub-type assignments. */
  801. #define AREAGROUP     1    /* These are used in the areaObj 'types' field. */
  802. #define AREARECT      2
  803. #define AREARRECT     3
  804. #define AREAOVAL      4
  805. #define AREAPOLY      5
  806.  
  807.  
  808. #define medleyMainType    0x54
  809. #define medleyAuxType     0xDD3E
  810. #define medleyInfo        1
  811. #define auxDictType       2
  812.  
  813.  
  814. #define ARTCONTENT    0    /* These are used in the 'contentType' field of 
  815.                               area objects.*/
  816. #define WWDOWN        1
  817. #define WWACROSS      2
  818. #define LWGRAYSCALE   0x0001
  819.  
  820.  
  821. #define SAMEESC       0    /* These are used in paragraph objects. */
  822. #define FONTESC       1
  823. #define SUPERESC      2
  824. #define SUBESC        3
  825. #define ESCAPES       7
  826.  
  827.  
  828. #define SIZEFONTESC   5    /* More paragraph equates. */
  829. #define ENDPGPHCHR    0xA6
  830. #define TABCHR        9
  831. #define SOFTHYPHEN    30
  832. #define STICKYSPACE   31
  833.  
  834.  
  835. #define PAGEBREAK     0x80  /* These are used in the pgphObj 'flags' field. */
  836. #define LEFTJUST      0x00
  837. #define RIGHTJUST     0x01
  838. #define CENTERJUST    0x02
  839. #define FULLJUST      0x03
  840. #define JUSTTYPES     0x03
  841.  
  842. #define LEFTTAB       0x00  /* These are used in the ruler field of paragraph 
  843.                                objects.  */
  844. #define RIGHTTAB      0x01
  845. #define CENTERTAB     0x02
  846. #define DECIMALTAB    0x03
  847. #define TABTYPES      0x03
  848. #define NOLEADER      0x00
  849. #define DOTSLEADER    0x01
  850. #define DASHESLEADER  0x02
  851. #define SOLIDLEADER   0x03
  852.  
  853. typedef struct Ruler {
  854.        unsigned char    leftPgphMrgn;
  855.        unsigned char    rightPgphMrgn;
  856.        unsigned char    pgphIndent;
  857.        unsigned char    numTabs;
  858.        unsigned int     tab[];
  859. } Ruler;
  860.  
  861. #define NEWREVNUM 0x0100
  862.  
  863.  
  864. typedef union URect {
  865.        Rect     rect;
  866.        struct {
  867.               long    p1;
  868.               long    p2;
  869.        } point;
  870.        struct {
  871.               Point   p1;
  872.               Point   p2;
  873.        } ele;
  874. } URect;
  875.  
  876. typedef union UPoint {
  877.        Point   ele;
  878.        long    point;
  879. } UPoint;
  880.  
  881. typedef struct region {
  882.        unsigned int    size;
  883.        union URect     BBox;
  884.        int             data[];
  885. } region;
  886.  
  887. typedef struct polygon {
  888.        int             size;
  889.        union URect     BBox;
  890.        union UPoint    point[];
  891. } polygon;
  892.  
  893. typedef union ourFontID {
  894.        unsigned long    fid;
  895.        struct {
  896.               unsigned int    famNum;
  897.               char            fontStyle;
  898.               char            fontSize;
  899.        } f;
  900. } ourFontID;
  901.  
  902. struct deskObj {
  903.       char             type;           $00
  904.       unsigned int     numChildren;    $01
  905.       unsigned long    endData;        $03
  906.       unsigned long    reserved;       $07
  907.       unsigned int     objRefNum;      $0B
  908.                                        $0D
  909.  
  910.     union d {
  911.         data[];           /*  Plain label object access field.  */
  912.  
  913.         struct file {           /*  Level 1 objects are files.  */
  914.               union URect       rect;                    /* $0D */
  915.               char              pathName[129];           /* $15 */
  916.               char              saved;                   /* $96 */
  917.               GrafPortPtr       windowPtr;               /* $97 */
  918.               char              windowNameIndx;          /* $9B */
  919.               long              windowOrigin;            /* $9C */
  920.               long              windowSize;              /* $A0 */
  921.               long              COrigin;                 /* $A4 */
  922.               struct deskObj    **editHndl;              /* $A8 */
  923.               unsigned int      editOffset;              /* $AC */
  924.               union URect       cursor;                  /* $AE */
  925.               char              showAllBorders;          /* $B6 */
  926.               union URect       updateRect;              /* $B7 */
  927.               unsigned long     topMrgn;                 /* $BF */
  928.               unsigned long     bottomMrgn;              /* $C3 */
  929.               unsigned long     leftMrgn;                /* $C7 */
  930.               unsigned long     rightMrgn;               /* $CB */
  931.               unsigned long     gutterMrgn;              /* $CF */
  932.               unsigned long     pageWidth;               /* $D3 */
  933.               unsigned long     pageHeight;              /* $D7 */
  934.               int               selectPage;              /* $DB */
  935.               int               numSelected;             /* $DD */
  936.               int               sizingDot;               /* $DF */
  937.               int               effectivePage;           /* $E1 */
  938.               PrRec             printRecord;             /* $E3 */
  939.               int               interruptMode;           /* $16F */
  940.               char              editScroll;              /* $171 */
  941.               struct deskObj    **firstHndl;             /* $172 */
  942.               int               firstMrn;                /* $176 */
  943.               unsigned int      selectMode;              /* $178 */
  944.               char              showPgphMarks;           /* $17A */
  945.               char              showSpaces;              /* $17B */
  946.               char              showMoveChangeInfo;      /* $17C */
  947.               union URect       moveChangeInfoRect;      /* $17D */
  948.               char              addNewUndo;              /* $185 */
  949.               unsigned int      revNum;                  /* $186 */
  950.               char              showRulers;              /* $188 */
  951.               unsigned int      windowType;              /* $189 */
  952.               char              auxDictPathname[129];    /* $18B */
  953.               unsigned int      grayScale;               /* $20C */
  954.               unsigned int      printRecordDefined;      /* $20E */
  955.               char              evenPageNumText[48];     /* $210 */
  956.               char              oddPageNumText[48];      /* $240 */
  957.               unsigned int      pageNumInfo[MAXNUMPAGES];/* $270 */
  958.               unsigned int      affectPageRange;         /* $2B0 */
  959.               ourFontID         pageNumFont;             /* $2B2 */
  960.               unsigned int      startPageNum;            /* $2B6 */
  961.               unsigned int      offsetFromEdge;          /* $2B8 */
  962.               unsigned int      maxNumPages;             /* $2BA */
  963.               unsigned int      condensed;               /* $2BC */
  964.               char              reserved[6];             /* $2BE */
  965.         } file;                                          /* $2C4 */
  966.  
  967.         struct page {
  968.               union URect       rect;                    /* $0D */
  969.               char              wrapDir;                 /* $15 */
  970.               region            **rgn;                   /* $16 */
  971.               char              hideGlobalArt;           /* $1A */
  972.               char              hideGlobalPageParts;     /* $1B */
  973.         } page;                                          /* $1C */
  974.  
  975.         struct pgph {          /*  Must be level 2 or greater.  */
  976.               unsigned int      wrapHere;                /* $0D */
  977.               unsigned int      fullWrap;                /* $0F */
  978.               unsigned int      rulerOffset;             /* $11 */
  979.               unsigned int      dataOffset;              /* $13 */
  980.               unsigned int      numRects;                /* $15 */
  981.               unsigned int      begInvOffset;            /* $17 */
  982.               unsigned int      endInvOffset;            /* $19 */
  983.               char              topLeading;              /* $1B */
  984.               char              botLeading;              /* $1C */
  985.               char              begPgphGap;              /* $1D */
  986.               char              endPgphGap;              /* $1E */
  987.               char              flags;                   /* $1F */
  988.             struct miniRect {                            /* $20 */
  989.                   union URect     rect;
  990.                   unsigned int    begOffset;
  991.                   unsigned int    endOffset;
  992.             } miniRect[];
  993. /*    Ruler goes here if there is a custom ruler for this paragraph.*/
  994. /*    Text starts after the ruler.  Text always 
  995.       starts with a fontEsc.  A fontEsc is 5 bytes, 
  996.       a typeByte followed by the fontID.  Text 
  997.       always ends with end-of-pgph chr. */
  998.         } pgph;                                          /* $20 */
  999.  
  1000.         struct area {
  1001.               char              type;                    /* $0D */
  1002.               char              select;                  /* $0E */
  1003.               char              showBorder;              /* $0F */
  1004.               char              contentType;             /* $10 */
  1005.               region            **rgn;                   /* $11 */
  1006.               region            **interiorRgn;           /* $15 */
  1007.               region            **sizingRgn;             /* $19 */
  1008.               unsigned int      flags;                   /* $1D */
  1009.               unsigned int      reserved;                /* $1F */
  1010.             union obj {
  1011.                 union  URect    rect;                    /* $21 */
  1012.                 struct rrect {
  1013.                        union URect     rect;             /* $21 */
  1014.                        int             height;           /* $29 */
  1015.                        int             width;            /* $2B */
  1016.                 } rrect;
  1017.                 union  URect    oval;                    /* $21 */
  1018.                 polygon         **poly;                  /* $21 */
  1019.             } obj;
  1020.         } area;                                          /* $2D */
  1021.  
  1022.         struct art {
  1023.               union URect     BBox;                      /* $0D */
  1024.               union UPoint    offsetFromRgn;             /* $15 */
  1025.               char            artImage[];                /* $19 */
  1026.         } art;
  1027.  
  1028.         struct docDict {
  1029.               unsigned int    count;                     /* $0D */
  1030.               char            wordList[]                 /* $0F */
  1031.         } docDict;                                       /* $0F */
  1032.  
  1033.     } d;
  1034. };